package com.function;

import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.CreateBucketRequest;
import com.aliyun.oss.model.DataRedundancyType;
import com.aliyun.oss.model.StorageClass;

public class CreateBucket {

    public static void main(String[] args) throws Exception {
        String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
        String accessKeyId = "LTAI5tFJzoBJnCUruixbSCAS";
        String accessKeySecret = "4QnvfNNEMMbYSBwmfkS8HJrxcONid8";
        String bucketName = "examplebucketn";

        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        // 创建CreateBucketRequest对象。
        CreateBucketRequest createBucketRequest = new CreateBucketRequest(bucketName);
        // 数据容灾类型默认为本地冗余存储，即DataRedundancyType.LRS。
        // 设置存储空间读写权限为公共读，默认为私有。
        // 创建存储空间。
        ossClient.createBucket(createBucketRequest);

        ossClient.shutdown();
        }
}
